import cv2
import numpy as np
import requests
from loguru import logger


def get_rasip_photo(url:str,is_raw=False):
    try:
        response = requests.get(url, timeout=3)
    except requests.exceptions.Timeout:
        logger.error("请求超时:树莓派拍照功能故障")
        return None 
    else:
        if is_raw:
            return response.content
        # 如果请求成功，处理响应内容
        im = response.content
        return cv2.imdecode(np.array(bytearray(im),dtype='uint8'),cv2.IMREAD_UNCHANGED)